\hypertarget{classSunnet}{\section{Sunnet Class Reference}
\label{classSunnet}\index{Sunnet@{Sunnet}}
}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classSunnet_a437f21dbd8b9e165b7f83c5a390413c5}{{\bfseries Sunnet} (const \hyperlink{classSunnet}{Sunnet} \&)=delete}\label{classSunnet_a437f21dbd8b9e165b7f83c5a390413c5}

\item 
\hypertarget{classSunnet_a2187d4973b2207e793d1a418451b127a}{const \hyperlink{classSunnet}{Sunnet} {\bfseries operator=} (const \hyperlink{classSunnet}{Sunnet} \&)=delete}\label{classSunnet_a2187d4973b2207e793d1a418451b127a}

\item 
\hypertarget{classSunnet_ad3da9d9474976109f3ca56ae764a263d}{void \hyperlink{classSunnet_ad3da9d9474976109f3ca56ae764a263d}{Start} ()}\label{classSunnet_ad3da9d9474976109f3ca56ae764a263d}

\begin{DoxyCompactList}\small\item\em 入口函数 \end{DoxyCompactList}\item 
\hypertarget{classSunnet_a48630e173ced99d2e0edb9a5dc49b3d5}{void {\bfseries Wait} ()}\label{classSunnet_a48630e173ced99d2e0edb9a5dc49b3d5}

\item 
\hypertarget{classSunnet_a54f240a242f4ef768587c8c947ba5e2a}{uint32\-\_\-t {\bfseries New\-Service} (std\-::shared\-\_\-ptr$<$ std\-::string $>$ type)}\label{classSunnet_a54f240a242f4ef768587c8c947ba5e2a}

\item 
void \hyperlink{classSunnet_a4323a7422ebab350b4af493a431491fc}{Kill\-Service} (uint32\-\_\-t id)
\begin{DoxyCompactList}\small\item\em 只能由service自己调用，里面会调用service中的方法，线程不安全 \end{DoxyCompactList}\item 
void \hyperlink{classSunnet_ab7e6397c09a8eb2823583e03bd661528}{Send} (uint32\-\_\-t dest\-\_\-id, std\-::shared\-\_\-ptr$<$ \hyperlink{classBaseMsg}{Base\-Msg} $>$ msg)
\begin{DoxyCompactList}\small\item\em 向目的service发送msg \end{DoxyCompactList}\item 
std\-::shared\-\_\-ptr$<$ \hyperlink{classService}{Service} $>$ \hyperlink{classSunnet_a58dfe55971a5ba93d777254c054440e7}{Pop\-Global\-Queue} ()
\begin{DoxyCompactList}\small\item\em 从global\-\_\-queue中弹出一个需要处理msg的service \end{DoxyCompactList}\item 
void \hyperlink{classSunnet_a90ad5612f54baa9c7910c7711cc41eec}{Push\-Global\-Queue} (std\-::shared\-\_\-ptr$<$ \hyperlink{classService}{Service} $>$ srv)
\begin{DoxyCompactList}\small\item\em 将一个需要处理msg的service放进global\-\_\-queue \end{DoxyCompactList}\item 
std\-::shared\-\_\-ptr$<$ \hyperlink{classServiceMsg}{Service\-Msg} $>$ \hyperlink{classSunnet_a075ba56d648e7beb726cfddf64581593}{Make\-Msg} (uint32\-\_\-t source, char $\ast$buff, int len)
\begin{DoxyCompactList}\small\item\em 临时构造\-Service\-Msg \end{DoxyCompactList}\item 
\hypertarget{classSunnet_a995cb65d66f6fee3667fe248a0eb8f2e}{void \hyperlink{classSunnet_a995cb65d66f6fee3667fe248a0eb8f2e}{Check\-And\-Weak\-Up} ()}\label{classSunnet_a995cb65d66f6fee3667fe248a0eb8f2e}

\begin{DoxyCompactList}\small\item\em Send方法中调用 \end{DoxyCompactList}\item 
std\-::shared\-\_\-ptr$<$ \hyperlink{classService}{Service} $>$ \hyperlink{classSunnet_a27842038d2fc4338d44539d95a9a576a}{Get\-Service} (uint32\-\_\-t id)
\begin{DoxyCompactList}\small\item\em 当global\-\_\-queue中没有srv时，工作线程调用该方法 \end{DoxyCompactList}\item 
\hypertarget{classSunnet_a933d43dfa53a71613d60fb1e77e624e5}{void {\bfseries Worker\-Wait} ()}\label{classSunnet_a933d43dfa53a71613d60fb1e77e624e5}

\item 
\hypertarget{classSunnet_a7f229f00285bbf68baa9b09911c160d8}{int {\bfseries Add\-Conn} (int fd, uint32\-\_\-t id, Conn\-::\-Type type)}\label{classSunnet_a7f229f00285bbf68baa9b09911c160d8}

\item 
\hypertarget{classSunnet_a9a5bae411d025f900eb7b0fdff5f632e}{std\-::shared\-\_\-ptr$<$ \hyperlink{classConn}{Conn} $>$ {\bfseries Get\-Conn} (int fd)}\label{classSunnet_a9a5bae411d025f900eb7b0fdff5f632e}

\item 
\hypertarget{classSunnet_a17ec755e62710b6f1a7e675db6330273}{bool {\bfseries Remove\-Conn} (int fd)}\label{classSunnet_a17ec755e62710b6f1a7e675db6330273}

\item 
\hypertarget{classSunnet_a73fe43fd59623ba7020d7676cb28c90d}{int {\bfseries Listen} (uint32\-\_\-t port, uint32\-\_\-t service\-\_\-id)}\label{classSunnet_a73fe43fd59623ba7020d7676cb28c90d}

\item 
\hypertarget{classSunnet_afab5f593cff45508f4e290990dda0b6a}{void {\bfseries Close\-Conn} (uint32\-\_\-t fd)}\label{classSunnet_afab5f593cff45508f4e290990dda0b6a}

\item 
\hypertarget{classSunnet_a6b6caead51659cbaeef4e758a88310c2}{void {\bfseries Modify\-Event} (int fd, bool epoll\-\_\-out)}\label{classSunnet_a6b6caead51659cbaeef4e758a88310c2}

\item 
\hypertarget{classSunnet_a961d69c9cf2ac01119b2a8bc3e85fea7}{void {\bfseries Send\-Msg2\-Log\-Service} (std\-::shared\-\_\-ptr$<$ \hyperlink{classLogMsg}{Log\-Msg} $>$ msg)}\label{classSunnet_a961d69c9cf2ac01119b2a8bc3e85fea7}

\end{DoxyCompactItemize}
\subsection*{Static Public Member Functions}
\begin{DoxyCompactItemize}
\item 
static \hyperlink{classSunnet}{Sunnet} \& \hyperlink{classSunnet_ad262ca0afa68db52846f39484c80291a}{Get\-Instance} ()
\begin{DoxyCompactList}\small\item\em Get the Instance object. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Public Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classSunnet_a952f4a90d681cc474d90649231938ed1}{int {\bfseries worker\-\_\-num\-\_\-} = common\-::\-W\-O\-R\-K\-E\-R\-\_\-\-N\-U\-M}\label{classSunnet_a952f4a90d681cc474d90649231938ed1}

\item 
\hypertarget{classSunnet_ad1afa1a7af752abcb78fc3409b9b940d}{std\-::vector$<$ std\-::shared\-\_\-ptr\\*
$<$ \hyperlink{classWorker}{Worker} $>$ $>$ {\bfseries workers\-\_\-vec\-\_\-}}\label{classSunnet_ad1afa1a7af752abcb78fc3409b9b940d}

\item 
\hypertarget{classSunnet_ace4e9ca8d82e73515a061806c0b216e0}{std\-::vector$<$ std\-::shared\-\_\-ptr\\*
$<$ std\-::thread $>$ $>$ {\bfseries worker\-\_\-thread\-\_\-vec\-\_\-}}\label{classSunnet_ace4e9ca8d82e73515a061806c0b216e0}

\item 
\hypertarget{classSunnet_a31930ea652d6d1b02e85dc2e4c53f845}{pthread\-\_\-mutex\-\_\-t {\bfseries sleep\-\_\-mutex\-\_\-}}\label{classSunnet_a31930ea652d6d1b02e85dc2e4c53f845}

\item 
\hypertarget{classSunnet_ae4c9f59269e7e0f53af8964b26c78cf9}{pthread\-\_\-cond\-\_\-t {\bfseries sleep\-\_\-cond\-\_\-}}\label{classSunnet_ae4c9f59269e7e0f53af8964b26c78cf9}

\item 
\hypertarget{classSunnet_a2ac612ac3c90e7831978b5743d635818}{int {\bfseries sleep\-\_\-count\-\_\-} = 0}\label{classSunnet_a2ac612ac3c90e7831978b5743d635818}

\item 
\hypertarget{classSunnet_a3b43790e7e57c02edf035ac6d402a569}{std\-::shared\-\_\-ptr$<$ \hyperlink{classSocketWorker}{Socket\-Worker} $>$ {\bfseries socket\-\_\-worker\-\_\-}}\label{classSunnet_a3b43790e7e57c02edf035ac6d402a569}

\item 
\hypertarget{classSunnet_ad1e25670a7a8e05982da962bfa485fb9}{std\-::shared\-\_\-ptr$<$ std\-::thread $>$ {\bfseries socket\-\_\-thread\-\_\-}}\label{classSunnet_ad1e25670a7a8e05982da962bfa485fb9}

\item 
\hypertarget{classSunnet_a3d17ec806b09511f15a9e4c67b4ecc6b}{std\-::unordered\-\_\-map$<$ uint32\-\_\-t, \\*
std\-::shared\-\_\-ptr$<$ \hyperlink{classConn}{Conn} $>$ $>$ {\bfseries conns\-\_\-}}\label{classSunnet_a3d17ec806b09511f15a9e4c67b4ecc6b}

\item 
\hypertarget{classSunnet_a5806a1ae562341b6934d06e539ad0459}{pthread\-\_\-rwlock\-\_\-t {\bfseries conns\-\_\-lock\-\_\-}}\label{classSunnet_a5806a1ae562341b6934d06e539ad0459}

\item 
\hypertarget{classSunnet_a9bd7cc85bc19a5d694676865ee25c15a}{std\-::unordered\-\_\-map$<$ uint32\-\_\-t, \\*
std\-::shared\-\_\-ptr$<$ \hyperlink{classService}{Service} $>$ $>$ {\bfseries service\-\_\-map\-\_\-}}\label{classSunnet_a9bd7cc85bc19a5d694676865ee25c15a}

\item 
\hypertarget{classSunnet_aa0c029e695d354a1b24e55721135e01c}{uint32\-\_\-t {\bfseries max\-\_\-id\-\_\-} = 0}\label{classSunnet_aa0c029e695d354a1b24e55721135e01c}

\item 
\hypertarget{classSunnet_add07371f5f7b9b884a74d14ed5a6df55}{pthread\-\_\-rwlock\-\_\-t {\bfseries services\-\_\-lock\-\_\-}}\label{classSunnet_add07371f5f7b9b884a74d14ed5a6df55}

\item 
\hypertarget{classSunnet_a738835db588add5d9a3239ebb37bc7db}{std\-::queue$<$ std\-::shared\-\_\-ptr\\*
$<$ \hyperlink{classService}{Service} $>$ $>$ {\bfseries global\-\_\-queue\-\_\-}}\label{classSunnet_a738835db588add5d9a3239ebb37bc7db}

\item 
\hypertarget{classSunnet_a6904c9876d78847ae2ae0211b95ff3df}{pthread\-\_\-spinlock\-\_\-t {\bfseries global\-\_\-queue\-\_\-lock\-\_\-}}\label{classSunnet_a6904c9876d78847ae2ae0211b95ff3df}

\item 
\hypertarget{classSunnet_a479f85aa89c20a018b51a0a710620a2f}{uint32\-\_\-t {\bfseries log\-\_\-service\-\_\-id\-\_\-}}\label{classSunnet_a479f85aa89c20a018b51a0a710620a2f}

\end{DoxyCompactItemize}


\subsection{Member Function Documentation}
\hypertarget{classSunnet_ad262ca0afa68db52846f39484c80291a}{\index{Sunnet@{Sunnet}!Get\-Instance@{Get\-Instance}}
\index{Get\-Instance@{Get\-Instance}!Sunnet@{Sunnet}}
\subsubsection[{Get\-Instance}]{\setlength{\rightskip}{0pt plus 5cm}static {\bf Sunnet}\& Sunnet\-::\-Get\-Instance (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [static]}}}\label{classSunnet_ad262ca0afa68db52846f39484c80291a}


Get the Instance object. 

\begin{DoxyReturn}{Returns}
\hyperlink{classSunnet}{Sunnet}\& 
\end{DoxyReturn}
\hypertarget{classSunnet_a27842038d2fc4338d44539d95a9a576a}{\index{Sunnet@{Sunnet}!Get\-Service@{Get\-Service}}
\index{Get\-Service@{Get\-Service}!Sunnet@{Sunnet}}
\subsubsection[{Get\-Service}]{\setlength{\rightskip}{0pt plus 5cm}std\-::shared\-\_\-ptr$<${\bf Service}$>$ Sunnet\-::\-Get\-Service (
\begin{DoxyParamCaption}
\item[{uint32\-\_\-t}]{id}
\end{DoxyParamCaption}
)}}\label{classSunnet_a27842038d2fc4338d44539d95a9a576a}


当global\-\_\-queue中没有srv时，工作线程调用该方法 

Get the \hyperlink{classService}{Service} object


\begin{DoxyParams}{Parameters}
{\em id} & service id \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
std\-::shared\-\_\-ptr$<$\-Service$>$ 
\end{DoxyReturn}
\hypertarget{classSunnet_a4323a7422ebab350b4af493a431491fc}{\index{Sunnet@{Sunnet}!Kill\-Service@{Kill\-Service}}
\index{Kill\-Service@{Kill\-Service}!Sunnet@{Sunnet}}
\subsubsection[{Kill\-Service}]{\setlength{\rightskip}{0pt plus 5cm}void Sunnet\-::\-Kill\-Service (
\begin{DoxyParamCaption}
\item[{uint32\-\_\-t}]{id}
\end{DoxyParamCaption}
)}}\label{classSunnet_a4323a7422ebab350b4af493a431491fc}


只能由service自己调用，里面会调用service中的方法，线程不安全 


\begin{DoxyParams}{Parameters}
{\em id} & \\
\hline
\end{DoxyParams}
\hypertarget{classSunnet_a075ba56d648e7beb726cfddf64581593}{\index{Sunnet@{Sunnet}!Make\-Msg@{Make\-Msg}}
\index{Make\-Msg@{Make\-Msg}!Sunnet@{Sunnet}}
\subsubsection[{Make\-Msg}]{\setlength{\rightskip}{0pt plus 5cm}std\-::shared\-\_\-ptr$<${\bf Service\-Msg}$>$ Sunnet\-::\-Make\-Msg (
\begin{DoxyParamCaption}
\item[{uint32\-\_\-t}]{source, }
\item[{char $\ast$}]{buff, }
\item[{int}]{len}
\end{DoxyParamCaption}
)}}\label{classSunnet_a075ba56d648e7beb726cfddf64581593}


临时构造\-Service\-Msg 


\begin{DoxyParams}{Parameters}
{\em source} & \\
\hline
{\em buff} & \\
\hline
{\em len} & \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
std\-::shared\-\_\-ptr$<$\-Service\-Msg$>$ 
\end{DoxyReturn}
\hypertarget{classSunnet_a58dfe55971a5ba93d777254c054440e7}{\index{Sunnet@{Sunnet}!Pop\-Global\-Queue@{Pop\-Global\-Queue}}
\index{Pop\-Global\-Queue@{Pop\-Global\-Queue}!Sunnet@{Sunnet}}
\subsubsection[{Pop\-Global\-Queue}]{\setlength{\rightskip}{0pt plus 5cm}std\-::shared\-\_\-ptr$<${\bf Service}$>$ Sunnet\-::\-Pop\-Global\-Queue (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{classSunnet_a58dfe55971a5ba93d777254c054440e7}


从global\-\_\-queue中弹出一个需要处理msg的service 

\begin{DoxyReturn}{Returns}
std\-::shared\-\_\-ptr$<$\-Service$>$ 
\end{DoxyReturn}
\hypertarget{classSunnet_a90ad5612f54baa9c7910c7711cc41eec}{\index{Sunnet@{Sunnet}!Push\-Global\-Queue@{Push\-Global\-Queue}}
\index{Push\-Global\-Queue@{Push\-Global\-Queue}!Sunnet@{Sunnet}}
\subsubsection[{Push\-Global\-Queue}]{\setlength{\rightskip}{0pt plus 5cm}void Sunnet\-::\-Push\-Global\-Queue (
\begin{DoxyParamCaption}
\item[{std\-::shared\-\_\-ptr$<$ {\bf Service} $>$}]{srv}
\end{DoxyParamCaption}
)}}\label{classSunnet_a90ad5612f54baa9c7910c7711cc41eec}


将一个需要处理msg的service放进global\-\_\-queue 


\begin{DoxyParams}{Parameters}
{\em srv} & \\
\hline
\end{DoxyParams}
\hypertarget{classSunnet_ab7e6397c09a8eb2823583e03bd661528}{\index{Sunnet@{Sunnet}!Send@{Send}}
\index{Send@{Send}!Sunnet@{Sunnet}}
\subsubsection[{Send}]{\setlength{\rightskip}{0pt plus 5cm}void Sunnet\-::\-Send (
\begin{DoxyParamCaption}
\item[{uint32\-\_\-t}]{dest\-\_\-id, }
\item[{std\-::shared\-\_\-ptr$<$ {\bf Base\-Msg} $>$}]{msg}
\end{DoxyParamCaption}
)}}\label{classSunnet_ab7e6397c09a8eb2823583e03bd661528}


向目的service发送msg 


\begin{DoxyParams}{Parameters}
{\em dest\-\_\-id} & 目的service id \\
\hline
{\em msg} & \\
\hline
\end{DoxyParams}


The documentation for this class was generated from the following file\-:\begin{DoxyCompactItemize}
\item 
/home/why/workspace/my\-\_\-skynet/include/\hyperlink{sunnet_8h}{sunnet.\-h}\end{DoxyCompactItemize}
